DO i = 0 FOR MM.Forward.Count ; PARSE VAR MM.Forward.i MM.Node User ; MM.User = 'USER:'TRANSLATE(STRIP(User),'_',' ')'/Pointers.msg' ; MM.xUser = 'USER:'TRANSLATE(STRIP(User),'_',' ')'/User.msg' ; CALL WriteLog('') ; CALL WriteLog('Processing user ['STRIP(User)']') ; IF EXISTS(MM.User) THEN DO
OPEN('User',MM.xUser,'R') ; SEEK('User',38,'B') ; NoRead = C2D(READCH('User',2)) + 1 ; Pointer.Count = 0 ; MM_ReadStem MM.User Pointer ; IF Pointer.1 = 0 | Pointer.Count = 1 | NoRead > Pointer.1 THEN DO ; CALL WriteLog('NO Messages Found.') ; END ; DO f = NoRead TO Pointer.1 ; Message = 'USER:'TRANSLATE(STRIP(User),'_',' ')'/'f'.MSG' ; IF EXISTS(Message) THEN DO ; OPEN('In',Message,'A') ; SEEK('In',165,'B') ; IF C2D(READCH('In',2)) = 0 THEN DO ; MM.Testo.Count = 0 ; CALL WriteLog('Message #'f 'Forwarded to' MM.Node) ; SEEK('In',0,'B') ; MM.FromName = StripEnd(READCH('In',36)) ; MM.ToName = StripEnd(READCH('In',36)) ; MM.Sogg = StripEnd(READCH('In',72)) ; MM.Date = READCH('In',19) ; SEEK('In',24) ; MM.BRead = C2D(READCH('In',2)) + 4 ; SEEK('In',1) ; DO p = 0 FOR MM.Messaggio.Count ; CALL AddLine(Trasforma(MM.Messaggio.p)) ; END ; DO WHILE ~EOF('In') ; CALL AddLine(READLN('In')) ; END
CALL AddLine('') ; CALL AddLine('-+- Forwarded By' MM.PrgName '-' MM.Copyright) ; CALL AddLine('') ; MM_WriteStem 'T:MM_DLGForward.Tmp' MM.Testo ; Write.From = MM.FromName ; Write.FromAddr = MM.Address ; Write.To = MM.ToName ; Write.ToAddr = MM.Node ; Write.Subj = MM.Sogg ; Write.Flags = 'PVT' ; Write.File = 'T:MM_DLGForward.Tmp' ; MM_WriteMsg MM.Mail Write ; SEEK('In',165,'B') ; WRITECH('In','1'x) ; SEEK('In',187,'B') ; WRITECH('In',D2C(MM.BRead)) ; MM.NumMsg = MM.NumMsg + 1 ; END ; ELSE CALL WriteLog('Message #'f 'already processed or netmail') ; CLOSE('In') ; END ; ELSE CALL WriteLog('Message #'f 'Not found.') ; END ; IF Pointer.1 <= 255 THEN SEEK('User',39,'B') ; ELSE SEEK('User',38,'B') ; WRITECH('User',D2C(Pointer.1)) ; CLOSE('User') ; END ; ELSE CALL WriteLog('NO Messages Found.') ; END ; IF MM.NumMsg > 0 THEN DO ; MM_GetAreaInfo MM.Mail Info ; Name = Info.Path||'Pointers.Msg' ; Pointer.Count = 0 ; MM_ReadStem Name Pointer ; Pointer.1 = Pointer.1 + MM.NumMsg ; MM_WriteStem Name Pointer ; END ; MM_Export MM.Mail ; CALL WriteLog(MM.PrgName 'Ended') ; EXIT
Replace: PROCEDURE ; PARSE ARG String, New, Old ; DO WHILE INDEX(String, Old) ~= 0 ; INTERPRET "PARSE VAR String l '"Old"' r" ; String = l || New || r ; END ; RETURN String
ReadConfig: PROCEDURE EXPOSE MM. ; MM.Forward.Count = 0 ; MM.Messaggio.Count = 0 ; MM.NumMsg = 0 ; MM.Address = '' ; MM.Mail = '' ; MM_ReadStem MM.PathCfg||'MM_DLGForward.Cfg' Config ; IF Rc ~= 0 THEN DO ; CALL WriteLog('*** Error: Can not open config "'MM.PathCfg'MM_MsgTrack.cfg"') ; EXIT 10 ; END ; DO l = 0 FOR Config.Count ; IF (LEFT(Config.l,1) ~= ';') & Config.l ~= '' THEN DO ; PARSE VAR Config.l Keyword Dato ; SELECT ; WHEN UPPER(Keyword) = '#MESSAGE' THEN MM_AddToStem MM.Messaggio 'Dato' ; WHEN UPPER(Keyword) = '#FORWARD' THEN MM_AddToStem MM.Forward 'Dato' ; WHEN UPPER(Keyword) = '#ADDRESS' THEN MM.Address = STRIP(Dato) ; WHEN UPPER(Keyword) = '#NETMAIL' THEN MM.Mail = STRIP(Dato) ; OTHERWISE ; END ; END ; END
IF MM.Address = '' THEN DO ; CALL WriteLog('Config parse error. You need to specify the Address') ; EXIT 10 ; END ; IF MM.Mail = '' THEN DO ; CALL WriteLog('Config parse error. You need to specify the Mail') ; EXIT 10 ; END ; RETURN